<?php

namespace App\Model;

use Illuminate\Database\Eloquent\Model;

/**
 * Class UserRecharge
 *
 * @package App\Model
 * @mixin \Eloquent
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\UserRecharge newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\UserRecharge newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\UserRecharge query()
 * @property int $id
 * @property int $user_id 会员id
 * @property float $money 金额
 * @property int $vip_fee_config_id 会员等级id
 * @property float|null $last_money 充值递减下次应付金额
 * @property string|null $overed_at 会员vip到期时间
 * @property string|null $last_at 递减最后到期时间
 * @property string $vip_fee_config_comment 会员等级描述
 * @property int $is_pay 是否支付
 * @property string|null $pay_time 支付时间
 * @property string $pay_type 支付类型：微信支付
 * @property string|null $appid 应用APPID
 * @property string|null $mch_id 商户号
 * @property string|null $nonce_str 随机字符串
 * @property string|null $sign 签名
 * @property string|null $out_trade_no 商户订单号
 * @property float|null $weixin_total_fee 微信返回支付金额
 * @property int $status 异步请求微信服务器判断支付成功状态
 * @property \Illuminate\Support\Carbon|null $created_at 创建时间
 * @property \Illuminate\Support\Carbon|null $updated_at 修改时间
 * @property string $deleted_at 删除时间
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\UserRecharge whereAppid($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\UserRecharge whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\UserRecharge whereDeletedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\UserRecharge whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\UserRecharge whereIsPay($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\UserRecharge whereLastAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\UserRecharge whereLastMoney($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\UserRecharge whereMchId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\UserRecharge whereMoney($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\UserRecharge whereNonceStr($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\UserRecharge whereOutTradeNo($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\UserRecharge whereOveredAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\UserRecharge wherePayTime($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\UserRecharge wherePayType($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\UserRecharge whereSign($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\UserRecharge whereStatus($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\UserRecharge whereUpdatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\UserRecharge whereUserId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\UserRecharge whereVipFeeConfigComment($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\UserRecharge whereVipFeeConfigId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\UserRecharge whereWeixinTotalFee($value)
 */
class UserRecharge extends Model
{
    protected  $table='user_recharges';

    /**
     * @param $data
     * @return bool
     */
    public function add($data)
    {
        $this->user_id = $data['user_id'];
        $this->money   = $data['money'];
        $this->vip_fee_config_id = $data['vip_fee_config_id'];
        $this->last_money = $data['last_money'];
        $this->overed_at = $data['overed_at'];
        $this->last_at = $data['last_at'];
        $this->vip_fee_config_comment = $data['vip_fee_config_comment'];
        $this->is_pay  = $data['is_pay'];
        $this->pay_time = $data['pay_time'];
        $this->pay_type  = $data['pay_type'];
        $this->appid = $data['app_id'];
        $this->mch_id = $data['mch_id'];
        $this->nonce_str = $data['nonce_str'];
        $this->sign = $data['sign'];
        $this->out_trade_no = $data['out_trade_no'];
        $this->status = $data['status'];
        return  $this->save();
    }
}
